/**
* @file qomodel.cpp
* @describe QoModel
* @author gaoyuelong
* @date 2022/05/07
*/

#include "qomodel.h"
#include "network/qotcp.h"

#include <QJsonObject>
#include <QJsonDocument>

QoModel::QoModel(QObject *parent) : QObject(parent)
{
    connect(QoTcp::getInstance(), SIGNAL(signalRecvMsg()), this, SLOT(slotRecvMsg()));
}

void QoModel::sendMsg(const QJsonObject &jsonObj)
{
    //发送消息
    QoTcp::getInstance()->sendMsg(QString(QJsonDocument(jsonObj).toJson(QJsonDocument::Compact)));
}

void QoModel::slotRecvMsg()
{
    QJsonObject recvMsgJsonObj;
    QoTcp::getInstance()->recvMsg(recvMsgJsonObj);
    emit signalRecvMsg(recvMsgJsonObj);
}
